import { createApp } from 'vue'
import App from './App.vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import 'element-plus/theme-chalk/dark/css-vars.css' // 暗黑模式
import router from './router'
import { createPinia } from 'pinia'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import './assets/CSS/all.css'

// 创建应用实例
const app = createApp(App)

// 创建并配置pinia
const pinia = createPinia()
pinia.use(piniaPluginPersistedstate)
// 实现pinia仓库的reset功能
pinia.use(({ store }) => {
	const initialState = JSON.parse(JSON.stringify(store.$state))
	store.$reset = () => {
		store.$patch(JSON.parse(JSON.stringify(initialState)))
	}
})

// 添加插件
app.use(router)
app.use(pinia)
app.use(ElementPlus)

// 挂载应用
app.mount('#app')
